//
//  QGInfomationCell.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/16.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//
//68 60 80

#import "GQInfomationCell.h"

@interface GQInfomationCell ()

@property (strong, nonatomic) UIImageView *imgView;
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *timeLabel;
@property (strong, nonatomic) UILabel *colletionCount;
@property (strong, nonatomic) UIImageView *colletionIcon;
@property (strong, nonatomic) UILabel *readCount;
@property (strong, nonatomic) UIImageView *readIcon;

@end

@implementation GQInfomationCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpChildView];
    }
    return self;
}

- (void)setUpChildView
{
    
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"icon"];
    self.imgView = imageView;
    [self addSubview:imageView];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont systemFontOfSize:15];
    titleLabel.text = @"古铜镜的收藏者之我有话要说第三十二期";
    titleLabel.numberOfLines = 0;
    self.titleLabel = titleLabel;
    [self addSubview:titleLabel];
    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.text = @"04-0 12:12";
    timeLabel.font = [UIFont systemFontOfSize:12];
    self.timeLabel = timeLabel;
    [self addSubview:timeLabel];
    
    //收藏量
    
    UILabel *colletionCount = [[UILabel alloc] init];
    colletionCount.text = @"585";
    colletionCount.font = [UIFont systemFontOfSize:12];
    self.colletionCount = colletionCount;
    [self addSubview:colletionCount];
    
    UIImageView *colletionIcon = [[UIImageView alloc] init];
    colletionIcon.image = [UIImage imageNamed:@"discover_collection"];
    self.colletionIcon = colletionIcon;
    [self addSubview:colletionIcon];

    //阅读量
    UILabel *readCount = [[UILabel alloc] init];
    readCount.text = @"585";
    readCount.font = [UIFont systemFontOfSize:12];
    self.readCount = readCount;
    [self addSubview:readCount];
    
    UIImageView *readIcon = [[UIImageView alloc] init];
    readIcon.image = [UIImage imageNamed:@"discover_reading"];
    self.readIcon = readIcon;
    [self addSubview:readIcon];

}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat margin = 10;
    CGFloat imageHeight = 60;
    CGFloat imageWidth = 80;
    CGFloat timeHeight = 16;
    CGFloat iconWidth = 17.5;
    CGFloat iconHeight = 16;
    CGFloat height = 68;
    
    self.imgView.frame = CGRectMake(margin, (height - 60) / 2, imageWidth, imageHeight);
    self.titleLabel.x = CGRectGetMaxX(self.imgView.frame) + margin;
    self.titleLabel.y = self.imgView.y;
    self.titleLabel.width = self.width - self.titleLabel.x - margin;
    self.titleLabel.height = 40;
    
    self.timeLabel.x = self.titleLabel.x;
    self.timeLabel.y = CGRectGetMaxY(self.imgView.frame) - timeHeight;
    self.timeLabel.width = 90;
    self.timeLabel.height = 18;
    
    self.colletionCount.x = self.width - margin - 25;
    self.colletionCount.y = CGRectGetMaxY(self.imgView.frame) - timeHeight;
    self.colletionCount.width = 25;
    self.colletionCount.height = 18;
    
    self.colletionIcon.x = CGRectGetMinX(self.colletionCount.frame) - iconWidth;
    self.colletionIcon.width = iconWidth;
    self.colletionIcon.height = iconHeight;
    self.colletionIcon.y = CGRectGetMaxY(self.timeLabel.frame) - iconHeight - 1;
    
    self.readCount.x = CGRectGetMinX(self.colletionIcon.frame) - 25 - 10;
    self.readCount.y = self.colletionCount.y;
    self.readCount.width = 25;
    self.readCount.height = 18;
    
    self.readIcon.x = CGRectGetMinX(self.readCount.frame) - 20;
    self.readIcon.y = self.colletionIcon.y;
    self.readIcon.width = iconWidth;
    self.readIcon.height = iconHeight;
    
}

@end
